package cn.edu.hqu.cst.android.activitylifecycle;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

public class ReturnResultActivity extends AppCompatActivity implements View.OnClickListener{
    EditText et_input;
    TextView tv_data;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_return_result);
        et_input=findViewById(R.id.et_return_result_activity_input);
        tv_data=findViewById(R.id.tv_return_result_activity_data);
        findViewById(R.id.btn_return_result_activity_return).setOnClickListener(this);
        tv_data.setText(getIntent().getExtras().getString("main_to_child"));

    }

    @Override
    public void onClick(View v) {
        Intent intent=getIntent();
        intent.putExtra("result_to_main",et_input.getText().toString());
        //设置返回结果到intent
        setResult(0x02,intent);
        switch (v.getId()){
            case R.id.btn_return_result_activity_return:
                finish();
                break;
        }
    }
}
